package com.syni.mdd.sjb.common.datatreaure.controller.protect;


import com.syni.mdd.sjb.common.component.utils.common.annotations.CheckUserIdentity;
import com.syni.mdd.sjb.common.datatreaure.controller.BaseController;
import com.syni.mdd.sjb.common.datatreaure.entity.vo.rp.userChannel.AddAlipayInfoVo;
import com.syni.mdd.sjb.common.datatreaure.entity.vo.rq.BaseRqVo;
import com.syni.mdd.sjb.common.datatreaure.entity.vo.rq.userChannel.*;
import com.syni.mdd.sjb.common.datatreaure.service.DxshAppUserChannelService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 * 电享生活app用户渠道表 前端控制器
 * </p>
 *
 * @author cfx
 * @since 2020-04-21
 */
@RestController
@RequestMapping("/userChannel")
public class DxshAppUserChannelController extends BaseController {

    @Autowired
    DxshAppUserChannelService dxshAppUserChannelService;


    @PostMapping("/getMyChannel")
    @ApiOperation(value = "获取我的渠道")
    @CheckUserIdentity
    public Map<String,Object> getMyChannel(@RequestBody @Validated GetMyChannelVo getMyChannelVo){
        return dxshAppUserChannelService.getMyChannel(getMyChannelVo);
    }

    @PostMapping("/getMddChannelList")
    @ApiOperation(value = "获取觅东东渠道列表")
    @CheckUserIdentity
    public Map<String,Object> getMddChannelList(@RequestBody @Validated BaseRqVo baseRqVo){
        return dxshAppUserChannelService.getMddChannelList(baseRqVo);
    }


    @PostMapping("/searchBusinessToClaim")
    @ApiOperation(value = "获取可以认领店铺")
    @CheckUserIdentity
    public Map<String,Object> searchBusinessToClaim(@RequestBody @Validated SearchBusinessToClaimVo searchBusinessToClaimVo){
        return dxshAppUserChannelService.searchBusinessToClaim(searchBusinessToClaimVo);
    }


    @PostMapping("/claimBusiness")
    @ApiOperation(value = "认领店铺")
    @CheckUserIdentity
    public Map<String,Object> claimBusiness(@RequestBody @Validated ClaimBusinessVo claimBusinessVo){
        return dxshAppUserChannelService.doClaimBusiness(claimBusinessVo);
    }

    @PostMapping("/claimBusiness/v2")
    @ApiOperation(value = "认领店铺")
    @CheckUserIdentity
    public Map<String,Object> claimBusiness_v2(@RequestBody ClaimBusinessVo claimBusinessVo){
        return dxshAppUserChannelService.doClaimBusiness_v2(claimBusinessVo);
    }

    @PostMapping("/claimBusiness/v3")
    @ApiOperation(value = "认领店铺")
    @CheckUserIdentity
    public Map<String,Object> claimBusiness_v3(@RequestBody ClaimBusinessVo claimBusinessVo){
        return dxshAppUserChannelService.doClaimBusiness_v3(claimBusinessVo);
    }

    @PostMapping("/certificationBusiness")
    @ApiOperation(value = "上传资质信息")
    @CheckUserIdentity
    public Map<String,Object> certificationBusiness(@RequestBody @Validated CertificationBusinessVo certificationBusinessVo){
        return dxshAppUserChannelService.certificationBusiness(certificationBusinessVo);
    }


    @PostMapping("/mddCertification")
    @ApiOperation(value = "觅东东上传资质信息")
    @CheckUserIdentity
    public Map<String,Object> mddCertification(@RequestBody @Validated CertificationBusinessVo certificationBusinessVo){
        return dxshAppUserChannelService.mddCertification(certificationBusinessVo);
    }


    @PostMapping("/getCertificationBusiness")
    @ApiOperation(value = "获取上传资质信息")
    @CheckUserIdentity
    public Map<String,Object> getCertificationBusiness(@RequestBody @Validated GetCertificationBusinessVo getCertificationBusinessVo){
        return dxshAppUserChannelService.getCertificationBusiness(getCertificationBusinessVo);
    }

    @PostMapping("/getCertificationBusiness/v2")
    @ApiOperation(value = "获取上传资质信息")
    @CheckUserIdentity
    public Map<String,Object> getCertificationBusiness_v2(@RequestBody @Validated GetCertificationBusinessVo getCertificationBusinessVo){
        return dxshAppUserChannelService.getCertificationBusiness_v2(getCertificationBusinessVo);
    }

    @PostMapping("/readyOnItInfo")
    @ApiOperation(value = "了解申请资料")
    @CheckUserIdentity
    public Map<String,Object> readyOnItInfo(@RequestBody @Validated GetMyChannelVo getMyChannelVo){
        Integer userId = getMyChannelVo.getUserId();
        Integer channelId = getMyChannelVo.getChannelId();
        return dxshAppUserChannelService.readyOnItInfo(userId,channelId);
    }

    @PostMapping("/minAppCertification")
    @ApiOperation(value = "小程序上传资质信息")
    @CheckUserIdentity
    public Map<String,Object> minAppCertification(@RequestBody @Validated CertificationBusinessVo certificationBusinessVo){
        return dxshAppUserChannelService.minAppCertification(certificationBusinessVo);
    }


    @PostMapping("/reSubmit")
    @ApiOperation(value = "小程序上传资质信息(再提交)")
    @CheckUserIdentity
    public Map<String,Object> reSubmit(@RequestBody @Validated CertificationBusinessVo certificationBusinessVo){
        return dxshAppUserChannelService.reSubmit(certificationBusinessVo);
    }



    @PostMapping("/addAlipayInfo")
    @ApiOperation(value = "补充觅东东专属资料")
    @CheckUserIdentity
    public Map<String,Object> addAlipayInfo(@RequestBody @Validated AddAlipayInfoVo addAlipayInfoVo){
        return dxshAppUserChannelService.createAlipay(addAlipayInfoVo);
    }

    @PostMapping("/searchAlreadyBusiness")
    @ApiOperation(value = "查询已认领店铺")
    @CheckUserIdentity
    public Map<String,Object> searchAlreadyBusiness(@RequestBody @Validated SearchAlreadyBusinessVo searchAlreadyBusinessVo){
        return dxshAppUserChannelService.searchAlreadyBusiness(searchAlreadyBusinessVo);
    }



    @PostMapping("/createBusiness")
    @ApiOperation(value = "创建店铺")
    @CheckUserIdentity
    public Map<String,Object> createBusiness(@RequestBody @Validated CreateBusinessVo createBusinessVo){
        return dxshAppUserChannelService.createBusiness(createBusinessVo);
    }

//    @PostMapping("/minNameCheck")
//    @ApiOperation(value = "检验小程序名称是否唯一")
//    @CheckUserIdentity
//    public Map<String,Object> minNameCheck(@RequestBody @Validated MinAppNameVo minAppNameVo){
//        return dxshAppUserChannelService.minNameCheck(minAppNameVo);
//    }

//    @PostMapping("/minHeadImgSurplus")
//    @ApiOperation(value = "获取小程序头像修改次数")
//    @CheckUserIdentity
//    public Map<String,Object> minHeadImgSurplus(@RequestBody @Validated BaseRqVo baseRqVo){
//        return dxshAppUserChannelService.minHeadImgSurplus(baseRqVo);
//    }

//    @PostMapping("/minSubmitInfo")
//    @ApiOperation(value = "小程序提交专属资料")
//    @CheckUserIdentity
//    public Map<String,Object> minSubmitInfo(@RequestBody @Validated MinExclusiveInfoVo minExclusiveInfoVo){
//        return dxshAppUserChannelService.minSubmitInfo(minExclusiveInfoVo);
//    }

    @PostMapping("/minSubmitInfo/v2")
    @ApiOperation(value = "小程序提交专属资料")
    @CheckUserIdentity
    public Map<String,Object> minSubmitInfo_v2(@RequestBody @Validated MinExclusiveInfoVo_v2 minExclusiveInfoVo){
        return dxshAppUserChannelService.minSubmitInfo_v2(minExclusiveInfoVo);
    }

    @PostMapping("/minAppCollectionInfo")
    @ApiOperation(value = "完善小程序收款信息")
    @CheckUserIdentity
    public Map<String,Object> minAppCollectionInfo(@RequestBody @Validated MinExclusiveInfoVo minExclusiveInfoVo){
        return dxshAppUserChannelService.minAppCollectionInfo(minExclusiveInfoVo);
    }

    @PostMapping("/getAppCollectionInfo")
    @ApiOperation(value = "获取小程序收款信息")
    @CheckUserIdentity
    public Map<String,Object> getAppCollectionInfo(@RequestBody @Validated MinExclusiveInfoVo minExclusiveInfoVo){
        return dxshAppUserChannelService.getAppCollectionInfo(minExclusiveInfoVo);
    }

    @PostMapping("/releaseMinAppPrepare")
    @ApiOperation(value = "小程序准备")
    @CheckUserIdentity
    public Map<String,Object> releaseMinAppPrepare(@RequestBody GetMyChannelVo getMyChannelVo){
        Integer channelId = getMyChannelVo.getChannelId();
        return dxshAppUserChannelService.releaseMinAppPrepare(channelId);
    }

    @PostMapping("/releaseMinApp")
    @ApiOperation(value = "发布小程序")
    @CheckUserIdentity
    public Map<String,Object> releaseMinApp(@RequestBody @Validated MinExclusiveInfoVo minExclusiveInfoVo){
        return dxshAppUserChannelService.releaseMinApp(minExclusiveInfoVo);
    }

    @PostMapping("/getBusinessDataById")
    @ApiOperation(value = "根据id获取店铺信息")
    @CheckUserIdentity
    public Map<String,Object> getBusinessDataById(@RequestBody @Validated GetBusinessDataByIdVo getBusinessDataByIdVo){
        return dxshAppUserChannelService.getBusinessDataById(getBusinessDataByIdVo);
    }

    @PostMapping("/updateBusinessData")
    @ApiOperation(value = "更新店铺信息")
    @CheckUserIdentity
    public Map<String,Object> updateBusinessData(@RequestBody @Validated UpdateBusinessDataVo updateBusinessDataVo){
        return dxshAppUserChannelService.updateBusinessData(updateBusinessDataVo);
    }

    @PostMapping("/getMinAppInfo")
    @ApiOperation(value = "获取小程序专属资料")
    @CheckUserIdentity
    public Map<String,Object> getMinAppInfo(@RequestBody @Validated MinAppInfoVo minAppInfoVo){
        return dxshAppUserChannelService.getMinAppInfo(minAppInfoVo);
    }

    @PostMapping("/getMinAppInfo/v2")
    @ApiOperation(value = "获取小程序专属资料")
    @CheckUserIdentity
    public Map<String,Object> getMinAppInfo_v2(@RequestBody @Validated MinAppInfoVo minAppInfoVo){
        return dxshAppUserChannelService.getMinAppInfo_v2(minAppInfoVo);
    }

    @PostMapping("/editMinAppInfo")
    @ApiOperation(value = "修改小程序信息")
    @CheckUserIdentity
    public Map<String,Object> editMinAppInfo(@RequestBody @Validated MinExclusiveInfoVo minExclusiveInfoVo){
        return dxshAppUserChannelService.editMinAppInfo(minExclusiveInfoVo);
    }

    @PostMapping("/getMinAppList")
    @ApiOperation(value = "获取小程序列表")
    @CheckUserIdentity
    public Map<String,Object> getMinAppList(@RequestBody @Validated BaseRqVo baseRqVo){
        return dxshAppUserChannelService.getMinAppList(baseRqVo);
    }

    @PostMapping("/cardToBank")
    @ApiOperation(value = "根据银行卡号获取到开户行")
    @CheckUserIdentity
    public Map<String,Object> cardToBank(@RequestBody @Validated CardInfoVo cardInfoVo){
        return dxshAppUserChannelService.cardToBank(cardInfoVo);
    }

    @PostMapping("/getBankByCity")
    @ApiOperation(value = "根据城市编码获取到银行支行")
    @CheckUserIdentity
    public Map<String,Object> getBankByCity(@RequestBody @Validated CityCodeVo cityCodeVo){
        return dxshAppUserChannelService.getBankByCity(cityCodeVo);
    }

    @PostMapping("/refreshQuickAccess")
    @ApiOperation(value = "刷新渠道快捷访问的点击时间")
    @CheckUserIdentity
    public Map<String,Object> refreshQuickAccess(@RequestBody @Validated RefreshQuickAccessVo refreshQuickAccessVo){
        return dxshAppUserChannelService.refreshQuickAccess(refreshQuickAccessVo);
    }

    @PostMapping("/getPayInfo")
    @ApiOperation(value = "获取觅东东支付信息")
    @CheckUserIdentity
    public Map<String,Object> getPayInfo(@RequestBody @Validated GetPayInfoVo getPayInfoVo){
        return dxshAppUserChannelService.getPayInfo(getPayInfoVo);
    }

    @PostMapping("/getMyStore")
    @ApiOperation(value = "获取我的门店列表")
    @CheckUserIdentity
    public Map<String,Object> getMyStore(@RequestBody BaseRqVo baseRqVo){
        Integer userId = baseRqVo.getUserId();
        Integer pageSzie = baseRqVo.getPageSize();
        Integer pageNum = baseRqVo.getPageNum();
        return dxshAppUserChannelService.getMyStore(userId,pageNum,pageSzie);
    }

//    @PostMapping("/getMyStore/v2")
//    @ApiOperation(value = "获取我的渠道列表")
//    @CheckUserIdentity
//    public Map<String,Object> getMyStore_v2(@RequestBody BaseRqVo baseRqVo){
//        Integer userId = baseRqVo.getUserId();
//        return dxshAppUserChannelService.getMyAllChannel(userId);
//    }

    @PostMapping("/getMyAllChannel")
    @ApiOperation(value = "获取我的渠道列表")
    @CheckUserIdentity
    public Map<String,Object> getMyAllChannel(@RequestBody BaseRqVo baseRqVo){
        Integer userId = baseRqVo.getUserId();
        return dxshAppUserChannelService.getMyAllChannel(userId,baseRqVo.getPageNum(),baseRqVo.getPageSize());
    }

    @PostMapping("/getSubdividedIndustry")
    @ApiOperation(value = "获取小程序细分行业接口")
    @CheckUserIdentity
    public Map<String,Object> getSubdividedIndustry(@RequestBody BaseRqVo baseRqVo){
        Integer userId = baseRqVo.getUserId();
        return dxshAppUserChannelService.getSubdividedIndustry(userId);
    }

    @PostMapping("/chooseSubdividedIndustry")
    @ApiOperation(value = "选择小程序行业")
    @CheckUserIdentity
    public Map<String,Object> chooseSubdividedIndustry(@RequestBody GetMyChannelVo getMyChannelVo){
        return dxshAppUserChannelService.chooseSubdividedIndustry(getMyChannelVo);
    }


    @PostMapping("/readyOnIt")
    @ApiOperation(value = "准备好了按钮")
    @CheckUserIdentity
    public Map<String,Object> readyOnIt(@RequestBody GetMyChannelVo getMyChannelVo){
        Integer channelId = getMyChannelVo.getChannelId();
        return dxshAppUserChannelService.readyOnIt(channelId);
    }


    @PostMapping("/addChannel")
    @ApiOperation(value = "新增我的渠道")
    @CheckUserIdentity
    public Map<String,Object> addChannel(@RequestBody AddChannelVo addChannelVo){
        Integer userId = addChannelVo.getUserId();
        Integer channel = addChannelVo.getChannel();
        Integer businessId = addChannelVo.getBusinessId();
        return dxshAppUserChannelService.addChannel(userId,businessId,channel);
    }

    @PostMapping("/addChannel/v2")
    @ApiOperation(value = "新增我的渠道")
    @CheckUserIdentity
    public Map<String,Object> addChannel_v2(@RequestBody AddChannelVo addChannelVo){
        Integer userId = addChannelVo.getUserId();
        Integer channel = addChannelVo.getChannel();
        return dxshAppUserChannelService.addChannel_v2(userId,channel);
    }

    @PostMapping("/getAppDemoList")
    @ApiOperation(value = "获取小程序模板")
    @CheckUserIdentity
    public Map<String,Object> getAppDemoList(@RequestBody BaseRqVo baseRqVo){
        return dxshAppUserChannelService.getAppDemoList();
    }

    @PostMapping("/getAppDemoList/v2")
    @ApiOperation(value = "获取小程序模板")
    @CheckUserIdentity
    public Map<String,Object> getAppDemoList_v2(@RequestBody BaseRqVo baseRqVo){
        return dxshAppUserChannelService.getAppDemoList_v2(baseRqVo);
    }

    @PostMapping("/getAppDemoDetail")
    @ApiOperation(value = "获取小程序模板详情")
    @CheckUserIdentity
    public Map<String,Object> getAppDemoDetail(@RequestBody GetMyChannelVo getMyChannelVo){
        String demoId = getMyChannelVo.getDemoId();
        Integer userId = getMyChannelVo.getUserId();
        return dxshAppUserChannelService.getAppDemoDetail(userId,demoId);
    }

    @PostMapping("/chooseMinAppDemo")
    @ApiOperation(value = "选择小程序模板")
    @CheckUserIdentity
    public Map<String,Object> chooseMinAppDemo(@RequestBody GetMyChannelVo getMyChannelVo){
        String demoId = getMyChannelVo.getDemoId();
        Integer channelId = getMyChannelVo.getChannelId();
        return dxshAppUserChannelService.chooseMinAppDemo(channelId,demoId);
    }

    @PostMapping("/minAppShare")
    @ApiOperation(value = "小程序分享图片")
    @CheckUserIdentity
    public Map<String,Object> minAppShare(@RequestBody @Validated GetMyChannelVo getMyChannelVo){
        Integer channelId = getMyChannelVo.getChannelId();
        return dxshAppUserChannelService.minAppShare(channelId);
    }


    /*@GetMapping("/test")
    @ApiOperation(value = "获取我的渠道")
    @CheckUserIdentity
    public void test(HttpServletResponse response){
        File file = CDNUtils.downLoadCdnFile("http://dsp-1251624226.cos.ap-guangzhou.myqcloud.com/dsp/20200422162329559.jpg");
        CDNUtils.flushToChomd(file,response);
    }*/





}
